package agh.tk.markuptranslation;

public class Image extends AbstractComponent
{
	/**
	 * 
	 * @param leftChild - adres obrazka
	 * @param rightChild - (ew.)opis
	 */
	public Image(IComponent leftChild, IComponent rightChild) 
	{
		super(leftChild, rightChild);
	}
	@Override
	public String toDokuWiki()
	{
		StringBuilder stringBuilder = new StringBuilder() ;
		stringBuilder.append("{{") ;
		stringBuilder.append(super.toDokuWiki("|")) ;
		stringBuilder.append("}}") ;
		return stringBuilder.toString() ;
	}
	
	@Override
	public String toMediaWiki() { //Do rozbudowy
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append("[[File:");
		stringBuilder.append(super.toDokuWiki("|"));
		stringBuilder.append("]]");
		return stringBuilder.toString();
	}
	
	@Override
	public String toHTML() {
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append("<img src=\"");
		stringBuilder.append(leftChild.toHTML());
		if(!(leftChild instanceof ResizableImage))
			stringBuilder.append("\"");
		if(rightChild != null) {
			stringBuilder.append("alt=\"");
			stringBuilder.append(rightChild);
			stringBuilder.append("\"");
		}
		stringBuilder.append("/>");
		return stringBuilder.toString();
	}
	
	@Override
	public String toTxt2tags()
	{
		StringBuilder stringBuilder = new StringBuilder() ;
		stringBuilder.append('[') ;
		stringBuilder.append(leftChild.toTxt2tags()) ;
		stringBuilder.append(']') ;
		return stringBuilder.toString() ;
	}
}
